#include<func.h>
#include <mysql/field_types.h>
#include <mysql/mysql.h>
#include <stdlib.h>
#include "user_check.h"

int datebase_conect(MYSQL* pconn,MYSQL_STMT** stmt);

int prepare_count(MYSQL_STMT* stmt,MYSQL* pconn,const char* sql);
bool select_username(const char* username,MYSQL_STMT* stmt,MYSQL pconn);
bool insert_username(user_info_t*  user,MYSQL_STMT* stmt,MYSQL pcon);
int select_cryptpasswd(const char* username,MYSQL_STMT* stmr,MYSQL pconn,char* str);
int select_userid(const char* username,MYSQL_STMT* stmt,MYSQL pconn);
int insert_filetable(int parent_id,char* filename,int id,MYSQL_STMT* stmt,MYSQL pconn);
int select_rootpwd(int user_id,MYSQL_STMT* stmt,MYSQL pconn);
int update_pwd(int user_id,int pwd,MYSQL_STMT* stmt,MYSQL pconn);
/* int getDirId(MYSQL *pconn, int user_id, int parent_id, const char *dir_name); */
/* int updateUserPwd(MYSQL *pconn, int user_id, int pwd); */
/* int getParentDirId(MYSQL *pconn, int user_id, int dir_id); */
int getDirid(MYSQL *pconn, int user_id, int parent_id, const char *dir_name);
int updateExit(MYSQL pconn,MYSQL_STMT* stmt,int id);


bool if_md5_exist(char md5_result[],int n,int *filesize,MYSQL_STMT *stmt,MYSQL *pconn);
//bool insert_puts_file(MYSQL *conn,int pwd,char * filename,int user_id,char md5_result[],int n,int filesize);
bool insert_puts_file(MYSQL *conn, MYSQL_STMT *stmt, int parent_id, const char *filename, int owner_id, const char md5_result[],int n, int filesize);
bool get_md5_by_filename(int pwd,char *filename,char* md5_buffer,MYSQL_STMT *stmt,MYSQL *conn);
bool check_filename_exists_with_pwd( char *filename, int pwd,MYSQL *conn);

